<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;


/**
 * App\Models\OrderShipping
 *
 * @property int $id
 * @property int $uid 用户ID
 * @property int $order_id 订单ID
 * @property int $shipping_type
 * @property int $express_id 快递公司ID
 * @property string|null $express_name 快递名称
 * @property string|null $express_no 快递单号
 * @property string|null $consignee
 * @property string|null $phone
 * @property string|null $province
 * @property string|null $city
 * @property string|null $district
 * @property string|null $street
 * @property string|null $zipcode
 * @property string $created_at
 * @property string $updated_at
 * @property-read \App\Models\Order $order
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereCity($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereConsignee($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereDistrict($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereExpressId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereExpressName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereExpressNo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereOrderId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping wherePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereProvince($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereShippingType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereStreet($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\OrderShipping whereZipcode($value)
 * @mixin \Eloquent
 * @property-read \App\Models\Express $express
 */
class OrderShipping extends Model
{
    protected $table = 'order_shipping';
    protected $primaryKey = 'id';
    protected $guarded = ['id'];

    public $timestamps = false;

    public static function boot()
    {
        parent::boot(); // TODO: Change the autogenerated stub

        static::creating(function ($model){
            $model->created_at = time();
            $model->updated_at = time();
        });

        static::updating(function ($model){
            $model->updated_at = time();
        });
    }

    public function order()
    {
        return $this->belongsTo(Order::class, 'order_id', 'order_id');
    }

    public function express()
    {
        return $this->belongsTo(Express::class, 'express_id', 'id');
    }
}
